package com.lggry.innerClass3;

public class Test {
    public static void main(String[] args) {
        //目标：认识匿名内部类，搞清楚其基本作用
        //需求：学生，老师都要参加游泳比赛
        Swim s1 = new Swim() {
            @Override
            public void swimming() {
                System.out.println("学生游泳");
            }
        };
        start(s1);

        Swim s2 = new Swim() {
            @Override
            public void swimming() {
                System.out.println("老师游泳");
            }
        };
        start(s2);
    }
    //设计一个方法，可以接收老师和学生开始比赛
    public static void start(Swim s) {
        s.swimming();
    }
}

interface Swim {
    void swimming();
}
